﻿#region Copyright (c) 2010 R. Uittenbosch
/*
* Copyright (C) 2010 R. Uittenbosch
* 
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
* associated documentation files (the "Software"), to deal in the Software without restriction, including 
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the 
* following conditions:
* 
* The above copyright notice and this permission notice shall be included in all copies or substantial 
* portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO 
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace LinkedService.Mobile
{
  /// <summary>
  /// IDataRepository interface
  /// </summary>
  public interface IDataRepository
  {
    /// <summary>
    /// Retrieve the content from the given url, passing requestData of type Ti and
    /// converting the result to type To.
    /// </summary>
    /// <typeparam name="To"></typeparam>
    /// <typeparam name="Ti"></typeparam>
    /// <param name="requestUrl"></param>
    /// <param name="requestData"></param>
    /// <param name="httpMethod"></param>
    /// <returns></returns>
    To RetrieveContent<To, Ti>(string requestUrl, Ti requestData, HttpMethod httpMethod);

    /// <summary>
    /// Retrieve the content from the given url, passing requestData of type Ti and
    /// converting the result to type To.
    /// </summary>
    /// <typeparam name="To"></typeparam>
    /// <typeparam name="Ti"></typeparam>
    /// <param name="requestUrl"></param>
    /// <param name="requestData"></param>
    /// <returns></returns>
    To RetrieveContent<To, Ti>(string requestUrl, Ti requestData);

    /// <summary>
    /// Retrieve the content from the given url, passing requestData of type Ti and
    /// converting the result to string
    /// </summary>
    /// <typeparam name="Ti"></typeparam>
    /// <param name="requestUrl"></param>
    /// <param name="requestData"></param>
    /// <param name="httpMethod"></param>
    /// <returns></returns>
    string RetrieveContent<Ti>(string requestUrl, Ti requestData, HttpMethod httpMethod);

    /// <summary>
    /// Retrieve the content from the given url, passing requestData of type Ti and
    /// converting the result to string.
    /// </summary>
    /// <typeparam name="Ti"></typeparam>
    /// <param name="requestUrl"></param>
    /// <param name="requestData"></param>
    /// <returns></returns>
    string RetrieveContent<Ti>(string requestUrl, Ti requestData);

    /// <summary>
    /// Retrieve the content from the given url, converting the result to type To.
    /// </summary>
    /// <typeparam name="To"></typeparam>
    /// <param name="requestUrl"></param>
    /// <returns></returns>
    To RetrieveContent<To>(string requestUrl);

    /// <summary>
    /// Retrieve the content from the given url, converting the result to type To.
    /// </summary>
    /// <typeparam name="To"></typeparam>
    /// <param name="requestUrl"></param>
    /// <param name="httpMethod"></param>
    /// <returns></returns>
    To RetrieveContent<To>(string requestUrl, HttpMethod httpMethod);

    /// <summary>
    /// Retrieve the content from the given url, converting the result to string.
    /// </summary>
    /// <param name="requestUrl"></param>
    /// <returns></returns>
    string RetrieveContent(string requestUrl);

    /// <summary>
    /// Retrieve the content from the given url, converting the result to string.
    /// </summary>
    /// <param name="requestUrl"></param>
    /// <param name="httpMethod"></param>
    /// <returns></returns>
    string RetrieveContent(string requestUrl, HttpMethod httpMethod);

    /// <summary>
    /// The httpstatuscode of the last call.
    /// </summary>
    HttpStatusCode LastStatusCode { get; }

    /// <summary>
    /// Retrieve the last content in raw xml
    /// </summary>
    string LastRawContent { get;}

    /// <summary>
    /// Eventhandler that fires in case of an error
    /// </summary>
    event ErrorEventHandler OnError;

    /// <summary>
    /// Eventhandler that fires upon success of a call
    /// </summary>
    event EventHandler OnSuccess;

  }
}
